package tests;

public class TestAntArea {
	public static void main(String[] args) {
		int n = 10;
		int m = 15;
		int[][] tab;

		for (int i = 1; i < n - 1; i++) {
			for (int j = 1; j < m - 1; j++) {
				tab = new int[n][m];

				int[] cn = new int[7];
				int[] cm = new int[7];

				cn[0] = (i - 3) > 0 ? i - 3 : i - 3 + n - 2;
				cn[1] = (i - 2) > 0 ? i - 2 : i - 2 + n - 2;
				cn[2] = (i - 1) > 0 ? i - 1 : i - 1 + n - 2;
				cn[3] = i;
				cn[4] = (i + 1) < (n - 1) ? i + 1 : i + 1 - (n - 2);
				cn[5] = (i + 2) < (n - 1) ? i + 2 : i + 2 - (n - 2);
				cn[6] = (i + 3) < (n - 1) ? i + 3 : i + 3 - (n - 2);

				cm[0] = (j - 3) > 0 ? j - 3 : j - 3 + m - 2;
				cm[1] = (j - 2) > 0 ? j - 2 : j - 2 + m - 2;
				cm[2] = (j - 1) > 0 ? j - 1 : j - 1 + m - 2;
				cm[3] = j;
				cm[4] = (j + 1) < (m - 1) ? j + 1 : j + 1 - (m - 2);
				cm[5] = (j + 2) < (m - 1) ? j + 2 : j + 2 - (m - 2);
				cm[6] = (j + 3) < (m - 1) ? j + 3 : j + 3 - (m - 2);

				tab[cn[0]][cm[3]] = 1;
				tab[cn[1]][cm[2]] = 1;
				tab[cn[1]][cm[3]] = 1;
				tab[cn[1]][cm[4]] = 1;
				tab[cn[2]][cm[1]] = 1;
				tab[cn[2]][cm[2]] = 1;
				tab[cn[2]][cm[3]] = 1;
				tab[cn[2]][cm[4]] = 1;
				tab[cn[2]][cm[5]] = 1;
				tab[cn[3]][cm[0]] = 1;
				tab[cn[3]][cm[1]] = 1;
				tab[cn[3]][cm[2]] = 1;
				tab[cn[3]][cm[3]] = 1;
				tab[cn[3]][cm[4]] = 1;
				tab[cn[3]][cm[5]] = 1;
				tab[cn[3]][cm[6]] = 1;
				tab[cn[4]][cm[1]] = 1;
				tab[cn[4]][cm[2]] = 1;
				tab[cn[4]][cm[3]] = 1;
				tab[cn[4]][cm[4]] = 1;
				tab[cn[4]][cm[5]] = 1;
				tab[cn[5]][cm[2]] = 1;
				tab[cn[5]][cm[3]] = 1;
				tab[cn[5]][cm[4]] = 1;
				tab[cn[6]][cm[3]] = 1;

				for (int k = 1; k < n - 1; k++) {
					for (int l = 1; l < m - 1; l++) {

						int dx1 = Math.abs(l - j);
						int dy1 = Math.abs(k - i);

						int dx2 = m - dx1 - 2;
						int dy2 = n - dy1 - 2;

						int dx = dx1 > dx2 ? dx2 : dx1;
						int dy = dy1 > dy2 ? dy2 : dy1;

						boolean naArea = (dx + dy) <= 3;

						if ((naArea && tab[k][l] == 0)
								|| (!naArea && tab[k][l] == 1)) {
							System.out
									.printf(
											"i: %d, j: %d, k: %d, l: %d, naArea: %b, tab: %d\n",
											i, j, k, l, naArea, tab[k][l]);
							throw new RuntimeException();
						}
					}
				}
			}
		}
	}
}
